﻿namespace _5._8._02.Exceptions.Exceptions
{
    using System;

    public class CSharpExam : Exam
    {
        public const int MAX_EXAM_SCORE = 100;
        public const int MIN_EXAM_SCORE = 0;

        private int score;

        public CSharpExam(int score)
        {
            this.Score = score;
        }

        public int Score
        {
            get
            {
                return this.score;
            }

            private set
            {
                if (value < MIN_EXAM_SCORE)
                {
                    throw new ArgumentOutOfRangeException("score", "Score should not be negative");
                }

                if (value > MAX_EXAM_SCORE)
                {
                    throw new ArgumentOutOfRangeException("score", "Score should not be higher than 100");
                }

                this.score = value;
            }
        }

        public override ExamResult Check()
        {
            return new ExamResult(this.Score, MIN_EXAM_SCORE, MAX_EXAM_SCORE, "Exam results calculated by score.");
        }
    }
}